﻿using System;

namespace Cxuu.Common
{
    [Serializable]
    public class IPLocationInfo
    {
        /// <summary>
        /// IP
        /// </summary>
        public string Ip { get; set; } = "";
        /// <summary>
        /// 国家
        /// </summary>
        public string Country { get; set; } = "";
        /// <summary>
        /// 省份、地区
        /// </summary>
        public string Region { get; set; } = "";
        /// <summary>
        /// 城市
        /// </summary>
        public string City { get; set; } = "";
        /// <summary>
        /// 区县
        /// </summary>
        public string Area { get; set; } = "";
        /// <summary>
        /// 网络运营商
        /// </summary>
        public string ISP { get; set; } = "";

        /// <summary>
        /// 完整信息
        /// </summary>
        public string GetFullInfo()
        {
            if (string.IsNullOrEmpty(Country) && string.IsNullOrEmpty(Region) && string.IsNullOrEmpty(City) && string.IsNullOrEmpty(Area))
                return Ip;
            return string.Concat(Country, Region, City, Area, string.IsNullOrEmpty(ISP) ? "" : "-" + ISP);
        }

        /// <summary>
        /// 不包含 国家的完整信息
        /// </summary>
        public string GetFullRegionInfo()
        {
            if (string.IsNullOrEmpty(Region) && string.IsNullOrEmpty(City) && string.IsNullOrEmpty(Area))
                return Ip;
            return string.Concat(Region, City, Area, string.IsNullOrEmpty(ISP) ? "" : "-" + ISP);
        }
    }
}
